﻿namespace eg_079_继承
{
    internal class Program
    {
        class Circle
        {
            protected int radius;
            public int Radius { get { return radius; } }
            public double Volume { get; protected set; }
        }

        class Ball : Circle
        {
            public Ball(int radius)
            {
                this.radius = radius;
                Volume = 4 * Math.PI * radius * radius / 3;
            }
        }
        class Cylinder : Circle
        {
            public Cylinder(int radius, int height)
            {
                this.radius = radius;
                Volume = height * Math.PI * radius * radius;
            }
        }

        class Cone : Circle
        {
            public Cone(int radius, int high)
            {
                this.radius = radius;
                Volume = high * Math.PI * radius * radius;
            }
        }


        static void Main(string[] args)
        {
            Ball ball = new Ball(10);                           //实例化球体
            Console.WriteLine("半径为{0}的球体体积为{1:0.00}", ball.Radius, ball.Volume);
            Circle cylinder = new Cylinder(10, 10);             //实例化圆柱体
            Console.WriteLine("半径为{0}高度为{1}的圆柱体体积为{2:F3}", cylinder.Radius, 10,
                                  cylinder.Volume);
            Circle cone = new Cone(10, 10);                     //实例化圆锥体
            Console.WriteLine("半径为{0}高度为{1}的圆柱体体积为{2:#,#.#}", cone.Radius, 10,
                                  cone.Volume);
        }
    }
}